//
//  WellConfig.m
//  AlumniBook
//
//  Created by 喂！ on 2018/10/24.
//  Copyright © 2018年 well. All rights reserved.
//

#import "WellConfig.h"

@implementation WellConfig

static WellConfig *instance = nil;

#pragma mark - 单例模式初始化方法`
+(id)allocWithZone:(NSZone *)zone
{
    @synchronized(self)
    {
        if(instance==nil)
        {
            instance=[super allocWithZone:zone];
            
            return instance;
        }
    }
    return nil;
}

#pragma mark - 单例模式初始化
+(WellConfig *)sharedInstance
{
    if(!instance)
    {
        instance=[[self alloc] init];
        [instance initVariables];
        
        
        instance.webAddress = @"http://192.168.5.253:8080";
        instance.fileWebAddress = @"http://192.168.5.253:8098";
        //            instance.shareUrl = @"http://home.tztos.com/piprefactoring/";
        instance.shareUrl = @"http://ip2.tztos.com:8233/PIPdownload";
        instance.sharePicName = @"QRCode";

        
        instance.needInsertArray = [[NSMutableArray alloc] init];
    }
    return instance;
}

#pragma mark - 单例内容初始化
-(void)initVariables
{
    //db file
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSFileManager *fileMgr=[NSFileManager defaultManager];
    
    NSString *dir=[paths objectAtIndex: 0];
    self.homeDir=dir;
    
    self.localDir=[dir stringByAppendingPathComponent:@"LocalFile"];
    if(![fileMgr fileExistsAtPath:self.localDir])
    {
        [fileMgr createDirectoryAtPath:self.localDir withIntermediateDirectories:YES attributes:nil error:nil];
    }
}


#pragma mark - 获取服务器接口地址
+(NSString *)getWebServiceUrl
{
    //    //测试环境
    //    return [NSString stringWithFormat:@"%@/%@",[TOSConfig getWebAddress],@"webservice_pip_refactoring/api/MoService"];
    //    //正式环境
    ////    return [NSString stringWithFormat:@"%@/%@",[TOSConfig getWebAddress],@"webservice_pip_new/api/MoService"];

    return [WellConfig getWebAddress];

    
}

#pragma mark - 获取服务器地址
+(NSString *)getWebAddress
{
    return [WellConfig sharedInstance].webAddress;
}

#pragma mark - 获取文件服务器地址
+(NSString *)getFileWebAddress
{
    return [WellConfig sharedInstance].fileWebAddress;
}

#pragma mark - 获取文件服务webService接口地址
+(NSString *)getFileWebServiceUrl
{
    //    //测试环境
    //    return [NSString stringWithFormat:@"%@/%@",[TOSConfig getFileWebAddress],@"fileservice_pip_refactoring/api"];
    //    //正式环境
    ////    return [NSString stringWithFormat:@"%@/%@",[TOSConfig getFileWebAddress],@"fileservice_pip_new/api"];
    
    

    return [WellConfig getFileWebAddress];

}

@end
